<%@page import="com.wanmait.cookbook.vo.RecipeType"%>

<%@page import="com.wanmait.cookbook.vo.Province"%>

<%@page import="java.util.List"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

    <%String path = request.getContextPath(); %>

<!DOCTYPE html>

<!-- saved from url=(0034)https://www.douguo.com/upfood.html -->

<html lang="en">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<meta charset="UTF-8">

<title>上传您的美食菜谱 拿手家常菜-豆果美食</title>

<script type="text/javascript" src="<%=path%>/static/js/jquery-3.5.1.min.js"></script>

<link rel="icon" href="https://cp1.douguo.com/static/nweb/images/favicon.ico?v=1912" type="image/x-icon">

<link rel="stylesheet" href="https://cp1.douguo.com/static/nweb/css/main.css?st=01078">

<link rel="stylesheet" href="https://cp1.douguo.com/static/nweb/css/upfood.css?1126">

<script src="https://www.googletagservices.com/activeview/js/current/osd.js?cb=%2Fr20100101"></script>

<script src="https://pagead2.googlesyndication.com/pagead/js/r20201019/r20190131/show_ads_impl_fy2019.js" id="google_shimpl"></script>

<script src="https://hm.baidu.com/hm.js?f4fa5d56f272ae0a0777feec2184a97f"></script>

<script src="https://cp1.douguo.com/static/nweb/js/jquery.js?st=20190421"></script>

<script data-ad-client="ca-pub-6608973961595981" async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" data-checked-head="true"></script>

<script>

    var _hmt = _hmt || [];

    (function() {

      var hm = document.createElement("script");

      hm.src = "https://hm.baidu.com/hm.js?f4fa5d56f272ae0a0777feec2184a97f";

      var s = document.getElementsByTagName("script")[0];

      s.parentNode.insertBefore(hm, s);

    })();

    </script>

<link rel="preload" href="https://adservice.google.com/adsid/integrator.js?domain=www.douguo.com" as="script">

<script type="text/javascript" src="https://adservice.google.com/adsid/integrator.js?domain=www.douguo.com"></script>

<% List<RecipeType> findByRecipeType = (List<RecipeType>)request.getAttribute("findByRecipeType"); %>

</head>

<body>

<jsp:include page="/inc/head.jsp"></jsp:include>

<style>

    #deleteMotai .tip-txt{font-size:18px;display:inline-block;font-weight:normal;margin-top:10px;}

    .draft-tip{text-align:center;display:none;}

    .draft-tip span{display:inline-block;padding:0 20px;height: 37px;line-height:37px;background: rgba(51, 51, 51, 0.3);border-radius: 37px;color:#fff;font-weight: bold;font-size: 15px;}

    

</style>

<div id="content" class="clearfix">

<div id="left">

<div class="draft-tip mt20">

<span>已保存到云端</span>

</div>

<!--上传封面图-->



<input class="coverImageUrl" onchange="changecover()" type="file"

name="image[]" id="coverImageUrl" value=""

accept="image/gif,image/jpeg,image/jpg,image/png,image/webp"

style="opacity: 0; z-index: 2; width: 10px; left: 1128px; top: 467px;">

<!--上传步骤图-->

<input type="file" name="image[]" class="buzhou" id="buzhou-file"

onchange="uploadBuZhouImg();"

accept="image/gif,image/jpeg,image/jpg,image/png,image/webp"

multiple="multiple"

style="position: absolute; display: block; opacity: 0; z-index: 2; width: 10px; filter: alpha(opacity = 0);">

<form action="<%=path %>/CookbookServlet?action=upCookbook" class="mt20" id="upfood" method="post" enctype="multipart/form-data">

<!--封面图的url-->

<input type="hidden" name="videoImgUrl" id="videoImgUrl" value="">

<input type="text" name="coverImgUrl" id="coverImgUrl" value=""

hidden="" style="display: none;"> <input type="hidden"

name="cook_id" value="" id="cook_id">

<div class="cover">

<%-- <div class="upbefore" id="uploadCookImage"

onmousemove="movefile(event,'coverImageUrl')">

<img src="<%=path %>/static/upCookbook_files/close.png" id="show">

<div class="tiptxt">

添加菜谱成品图

<p>（建议尺寸1280*1024，支持上传图片格式有jpg、jpeg、png、gif、webp）</p>

</div>



</div> --%>

<div class="upnow">正在上传…</div>

<input id="file100" class="filepath" name="foodPICCover" onchange="changepic(100)" type="file"><br>

<div class="upbefore" id="uploadCookImage"

onmousemove="movefile(event,'coverImageUrl')">

<img src="" id="show100" width="690px;" height="390px;"> 

    <!-- <div style="width:690px;height:544.531px;" > -->

    <!-- <div class="tiptxt">

添加菜谱成品图

<p>（建议尺寸1280*1024，支持上传图片格式有jpg、jpeg、png、gif、webp）</p> -->



   <!--  <img src="" id="show" width="690px;" height="390px;"> -->

  <!--   </div> -->

    </div>

<div class="upsucc">

<button type="button" class="reset-upcover"

onclick="$('#coverImageUrl').click();"></button>

</div>





<div class="caogao" style="display: none">

<div class="sydimg">

<div class="list">

<div class="listbox">

<ul>

</ul>

</div>

</div>

</div>

<div class="muti">

<span>草</span> <span>稿</span> <span>箱</span> <span

style="font-size: 11px" id="shannum">(

<p class="shannum">0</p>)

</span> <span id="jiaotou">&gt;&gt;</span>

</div>

</div>



</div>

<div class="name">

<input class="upname " id="cook_name" name="cook_name" type="text"

maxlength="30" value="菜谱名称"

onfocus="if(this.value=='菜谱名称') {this.value=''; $(this).addClass('fcbm'); }"

onblur="if(!this.value) {this.value='菜谱名称';$(this).removeClass('fcbm');} draft();">

</div>

<div class="restory pbm" style="margin-top: 20px;">

<select id="cook_difficulty" name="cook_difficulty" class="seleco"

onchange="draft();">

<option value="">烹饪难度</option>

<option value="1">切墩(初级)</option>

<option value="2">配菜(中级)</option>

<option value="3">掌勺(高级)</option>

</select> 

<select id="costtime" name="costtime" class="seleco"

onchange="draft();">

<option value="">烹饪时间</option>

<option value="1">10分钟左右</option>

<option value="2">10-30分钟</option>

<option value="3">30-60分钟</option>

<option value="4">1小时以上</option>

</select>

</div>

<div class="restory pbm" style="margin-top: 20px;">

<select id="recipeTypes" name="recipeTypes" class="seleco" ><!-- recipeType -->

<%

for(RecipeType recipeType:findByRecipeType){

%>

<option value="<%=recipeType.getId()%>"><%=recipeType.getTitle() %></option>

<%

}

%>

</select> 

<select id="recipeTypeSecond" name="recipeTypeSecond" class="seleco" ></select>

</div>

<div class="restory pbm" style="margin-top: 20px;">

<select id="cook_difficulty" name="taste" class="seleco"

onchange="draft();">

<option value="酸">酸</option>

<option value="甜">甜</option>

<option value="苦">苦</option>

<option value="辣">辣</option>

<option value="咸">咸</option>

</select> 

<select id="costtime" name="cooking_method" class="seleco"

onchange="draft();">

<option value="煎">煎</option>

<option value="炒">炒</option>

<option value="烹">烹</option>

<option value="炸">炸</option>

<option value="蒸">蒸</option>

<option value="烤">烤</option>

<option value="煮">煮</option>

<option value="生吃">生吃</option>

</select>

</div>

<div class="rory">

<textarea id="cookStory" class="strtext " name="cookStory"></textarea>

</div>

<div class="material clearfix">

<h2>食材清单</h2><span id="shiCai" style="color:red"></span>

<div class="zl-list mlist" id="zl-listmlist">

<div>

<span class="liaotit"> 食材</span><span class="liangtit"> 用量</span>

</div>

<div class="mct clearfix shiCai">

<input type="text" class="liaoext zhuliao foodName" name="zhuliao"

value="如:五花肉"

onfocus="if(this.value=='如:五花肉') {this.value=''; $(this).addClass('fcbm'); }"

onblur="if(!this.value) {this.value='如:五花肉';$(this).removeClass('fcbm');}">

<input type="text" class="liangext foodNumber" name="zhuliaoValue"

value="如:250g"

onfocus="if(this.value=='如:250g') {this.value=''; $(this).addClass('fcbm'); }"

onblur="if(!this.value) {this.value='如:250g';$(this).removeClass('fcbm');}">

<a href="javascript:void(0);" class="wrng" onclick="deleteThisEle(this)"></a>

</div>

<div class="mct clearfix shiCai">

<input type="text" class="liaoext zhuliao fcbm foodName" name="zhuliao" value="">

<input type="text" class="liangext fcbm foodNumber" name="zhuliaoValue" value="">

<a href="javascript:void(0);" class="wrng" onclick="deleteThisEle(this)"></a>

</div>

</div>

<a class="adlan" href="javascript:void(0);" id="zhuliao" >增加一栏</a>

</div>

<div class="step">

<h2>

步骤 <span style="font-size: 12px; font-weight: normal;">（支持上传图片格式有jpg、jpeg、png、gif、webp）</span>

</h2>


<ul class="step-list" id="step">

<input id="file1" class="filepathFood" name="foodPIC" onchange="changepic(1)" type="file"><br>

<img src="" id="show1" class="showIMG" width="200px;" height="200px;">

<textarea name="setpInfos" style="" class="steptext"></textarea> <br>



</ul>

<a class="addstep" id="addstep" href="javascript:void(0);" >增加一栏</a>

</div>

<div class="tips">

<h2>小贴士</h2>

<textarea name="cooktips" class="fcbm"

onfocus="if(this.value=='(选填)') {this.value=''; $(this).addClass('fcbm'); }"

onblur="if(!this.value) {this.value='(选填)';$(this).removeClass('fcbm');} draft();"> </textarea>

<label for="exclusive">  </label> 

<input type="hidden" name="_token" id="_token"

value="YD2sCqGUJ2inXEL8jfa1Wblz5qQ2MdUupiHAHGHB">

</div>

<input type="hidden" id="draft_id" name="draft_id" value="">

<input type="hidden" name="video" id="video" value=""> 

<input type="file" name="foodVidoe" id="vidoeFile" onchange="uploadVideos()"

hidden="" value="" accept="video/*"

style="position: absolute; left: -99999999px;"> <input

name="token" type="hidden"

value="PQPz49YjVeJ-uOdyqIwxyOn6aodL8dBI0ePyhHXX:t8rSoXRXflijHqOsTeIBUK4UCLw=:eyJjYWxsYmFja1VybCI6Imh0dHA6XC9cL2FwaS5kb3VndW8ubmV0XC91cGxvYWRcL3Fpbml1Y2FsbGJhY2siLCJjYWxsYmFja0JvZHkiOiJ7XCJrZXlcIjpcIiQoa2V5KVwiLFwiaGFzaFwiOlwiJChldGFnKVwiLFwiZnNpemVcIjokKGZzaXplKSxcImJ1Y2tldFwiOlwiJChidWNrZXQpXCIsXCJ1aWRcIjoyNjA0ODkzMyxcInR5cGVcIjoxfSIsImNhbGxiYWNrQm9keVR5cGUiOiJhcHBsaWNhdGlvblwvanNvbiIsInNjb3BlIjoiZG91Z3VvLWxpdmUiLCJkZWFkbGluZSI6MTYwMzI3NTc4M30=">



<a href="javascript:void(0)"

onclick="$('#vidoeFile').click();console.log('上传视频点了');"

class="upload-video" id="pickv">上传视频</a> <input type="hidden"

name="cvideo_id" id="cvideo_id" value=""> <input

type="hidden" name="src_url" id="src_url" value="">



<div class="video-more ">

<p>视频已上传成功，可以发布啦</p>

<a href="javascript:void(0)" id="reup"

style="display: inline-block; background: #FFB31A; padding: 12px; font-size: 16px; color: #ffffff; border-radius: 4px">重新选择视频</a>

<a href="javascript:void(0)" id="delup"

style="display: inline-block; background: #FFB31A; padding: 12px; font-size: 16px; color: #ffffff; border-radius: 4px">删除视频</a>

</div>



<div class="signupcode">

<input type="hidden" name="check" value="1"> <span>验证码：</span>

<input type="text" name="signupcode" id="signupcode"> <img

src="<%=path%>/CodeServlet?action=code" onclick="refreshcode()" title="验证码,看不清楚?请点击刷新验证码"

class="codeImg">

</div>

<input type="hidden" name="cookware" id="cookware" value="Array">

<div class="complete">

<a class="submit" id="sub" href="javascript:void(0)">发布</a> 

<a class="savedraft" href="javascript:void(0)" onclick="draft2()">存草稿</a>

</div>
<span id="tips" style="color:red;font-size:25px;"></span>

</form>

<img id="img-net" style="display: none;"

src="https://cp1.douguo.com/upload/photo/9/d/b/u13650692105313.jpeg?timestamp=1603268753000"

alt="">

<div id="netMotai"

style="position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; display: none; z-index: 10;">

<div

style="height: 100vh; background: black; opacity: 0.5; z-index: 999;"></div>

<div

style="position: fixed; width: 420px; height: 191px; margin-left: -210px; margin-top: -145px; top: 50%; left: 50%; background: #fff; border-radius: 8px; z-index: 1000; text-align: center; font-size: 0;">

<p

style="margin-top: 50px; margin-bottom: 60px; font-size: 20px; line-height: 20px; text-align: center; font-weight: bold">离线状态无法同步</p>

<button

style="width: 183px; height: 42px; margin-right: 10px; padding: 0; border-radius: 4px; background: #FFB31A; font-size: 18px; border: none; color: #ffffff; outline: none; cursor: pointer;"

onclick="$('#netMotai').hide();">确认</button>

</div>

</div>

</div>

</div>

<div id="footer">

<jsp:include page="/inc/foot.jsp"></jsp:include>

</div>

<ins class="adsbygoogle adsbygoogle-noablate"

data-adsbygoogle-status="done" style="display: none !important;">

<ins id="aswift_0_expand"

style="display: inline-table; border: none; height: 0px; margin: 0; padding: 0; position: relative; visibility: visible; width: 0px; background-color: transparent;">

<ins id="aswift_0_anchor"

style="display: block; border: none; height: 0px; margin: 0; padding: 0; position: relative; visibility: visible; width: 0px; background-color: transparent;">

<iframe id="aswift_0" name="aswift_0"

style="left: 0; position: absolute; top: 0; border: 0; width: undefinedpx; height: undefinedpx;"

sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation"

frameborder="0"

src="https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-6608973961595981&amp;output=html&amp;adk=1812271804&amp;adf=3025194257&amp;lmt=1603268583&amp;plat=1%3A32776%2C2%3A16809992%2C9%3A32776%2C10%3A32%2C11%3A32%2C16%3A8388608%2C17%3A32%2C24%3A32%2C25%3A32%2C30%3A1081344%2C32%3A32%2C40%3A32&amp;guci=2.2.0.0.2.2.0.0&amp;format=0x0&amp;url=https%3A%2F%2Fwww.douguo.com%2Fupfood.html&amp;ea=0&amp;flash=0&amp;pra=5&amp;wgl=1&amp;tt_state=W3siaXNzdWVyT3JpZ2luIjoiaHR0cHM6Ly9hZHNlcnZpY2UuZ29vZ2xlLmNvbSIsInN0YXRlIjowfV0.&amp;dt=1603268583681&amp;bpp=12&amp;bdt=114&amp;idt=62&amp;shv=r20201019&amp;cbv=r20190131&amp;ptt=9&amp;saldr=aa&amp;abxe=1&amp;nras=1&amp;correlator=18888503641&amp;frm=20&amp;pv=2&amp;ga_vid=1721754497.1603188130&amp;ga_sid=1603268584&amp;ga_hid=178880964&amp;ga_fc=1&amp;iag=0&amp;icsg=2344&amp;dssz=9&amp;mdo=0&amp;mso=8&amp;u_tz=480&amp;u_his=8&amp;u_java=0&amp;u_h=1080&amp;u_w=1920&amp;u_ah=1040&amp;u_aw=1920&amp;u_cd=24&amp;u_nplug=3&amp;u_nmime=4&amp;adx=-12245933&amp;ady=-12245933&amp;biw=1903&amp;bih=969&amp;scr_x=0&amp;scr_y=0&amp;eid=42530672&amp;oid=3&amp;pvsid=2528363619656626&amp;pem=579&amp;ref=https%3A%2F%2Fwww.douguo.com%2F&amp;rx=0&amp;eae=2&amp;fc=1920&amp;brdim=0%2C0%2C0%2C0%2C1920%2C0%2C1920%2C1040%2C1920%2C969&amp;vis=1&amp;rsz=%7C%7Cs%7C&amp;abl=NS&amp;fu=8200&amp;bc=31&amp;ifi=0&amp;uci=a!0&amp;fsb=1&amp;dtd=75"

marginwidth="0" marginheight="0" vspace="0" hspace="0"

allowtransparency="true" scrolling="no" allowfullscreen="true"

data-google-container-id="a!0" data-load-complete="true"></iframe>

</ins>

</ins>

</ins>

<script

src="https://cp1.douguo.com/static/nweb/js/ajaxfileupload.js?234"></script>

<iframe id="google_osd_static_frame_7645550640007"

name="google_osd_static_frame"

style="display: none; width: 0px; height: 0px;"></iframe>

<script

src="https://cp1.douguo.com/static/nweb/js/jquery.form.min.js?0604"></script>

<script src="https://cp1.douguo.com/static/nweb/js/gt.js?234"></script>

<script src="https://cp1.douguo.com/static/nweb/js/tip.js?v=2019"></script>

<script

src="https://cp1.douguo.com/static/nweb/js/search.js?v=12171145"></script>

<script src="https://cp1.douguo.com/static/nweb/js/main.js?v=201911"></script>

<!-- <script src='https://s13.cnzz.com/c.php?id=30029854' language='JavaScript' charset='gb2312'></script> -->



<script src="https://i1.douguo.com/static/nweb/js/Sortable.min.js"></script>

<script type="text/javascript">

function changepic() {

        var reads= new FileReader();

         f=document.getElementById('file').files[0]; 

         //获得一张图片

        /* f=document.getElementByClassName('filepath').files[0]; */


        reads.readAsDataURL(f);

        reads.onload=function (e) {

           /*  document.getElementsByClassName('showIMG').src=this.result; */

            document.getElementById('show').src=this.result;

        };

}

function changepic(i) {


        var reads= new FileReader();

         f=document.getElementById('file'+i).files[0]; 

        reads.readAsDataURL(f);

        reads.onload=function (e) {

            document.getElementById('show'+i).src=this.result;

        };

}



$(function(){

changeRecipeTypeSecond();

// 菜谱分类



$("#recipeTypes").change(changeRecipeTypeSecond);



function changeRecipeTypeSecond(){

var typeId = $("#recipeTypes").val();

$.ajax({

url:"<%=path%>/RecipeTypeServlet",

type:"get",

data:{action:"getRecipeTypeSecondByRecipeTypeId",recipeTypeId:typeId},

success:function(mes){

$("#recipeTypeSecond").html(mes);

}

}); 

}

// 点击更验证码

$(".codeImg").click(function(){

$(".codeImg").attr("src","<%=path%>/CodeServlet?action=code&rand="+Math.random());

});

var buZhou = 1;

var zhuliao = 2;

// 添加一栏食材

$("#zhuliao").click(function(){

zhuliao++;
$("#shiCai").html("");
$("<div class='mct clearfix shiCai'> <input type='text' class='liaoext zhuliao fcbm foodName' name='zhuliao' value=''> <input type='text' class='liangext fcbm foodNumber' name='zhuliaoValue' value=''> <a href='javascript:void(0);' class='wrng'></a> </div>").appendTo("#zl-listmlist");



});


// 删除一栏食材
$(".zl-list").on("click",".wrng",function(){
	if($(".shiCai").length<=1){
		$("#shiCai").html("最少添加一栏食材");
		return;
	}
	$(this).parent().remove();
});

// 添加一栏步骤

$("#addstep").click(function(){

buZhou++;

$("<br> <input id='file"+buZhou+"' class='filepathFood' name='foodPIC' onchange='changepic("+buZhou+")' type='file'><br> <img src='' id='show"+buZhou+"' class='showIMG' width='200px;' height='200px;'> <textarea name='setpInfos' style='' class='steptext'></textarea> <br>").appendTo("#step");

});


 function judge(){
alert("======");
if($("#file100").val()==""){
$("#tips").html("请上传封面图");
return false;
}
if($("#cook_name").val()=="菜谱名称"||$("#cook_name").val()==""){
$("#tips").html("请上传菜谱名称");
return false;
}
if($("#cook_difficulty").val()==""){
$("#tips").html("请选择烹饪难度");
return false;
}
if($("#costtime").val()==""){
$("#tips").html("请选择烹饪时间");
return false;
}
if($("#cookStory").val()==""){
$("#tips").html("请添加简介");
return false;
}
if($(".foodName").val()==""||$(".foodName").val()=="如:五花肉"){
$("#tips").html("请填写食材");
return false;
}
if($(".foodNumber").val()==""||$(".foodNumber").val()=="如:250g"){
$("#tips").html("请填写用量");
return false;
}
$(".filepathFood").each(function(){
if($(this).val()==""){
$("#tips").html("上传步骤图");
return false;
}
})
$(".steptext").each(function(){
if($(this).val()==""){
$("#tips").html("添加步骤说明");
return false;
}
}); 
};

/*点击发布按钮执行*/
$(".submit").click(function(){
if(judge()==false){
return;
}
var flag = true;
$.ajax({
	url:"<%=path%>/CookbookServlet",
	data:{action:"judgeCookBookName",cookBookName:$("#cook_name").val()},
	async:false,
	success:function(msg){
		if("true"==msg){
			$("#tips").html("请重新上传菜谱名称");
			flag=false;
		}
	}
})
if(flag==false){
	return;
}
var code = $("#signupcode").val();
$.ajax({
url:"<%=path%>/CodeServlet",
data:{action:"check",code:code},
async:false,
success:function(mes){
if("no"==mes){
$("#tips").html("验证码不正确");
$("#signupcode").select();
}
else{
$("#tips").html("");
$("#upfood").submit();
}
}
});
/* 	else{
$("#upfood").submit();
} */
});

$(".savedraft").click(function(){
if(judge()==false){
return;
}
else{
$("#upfood").attr("action","<%=path %>/CookbookServlet?action=savedraft");
$("#upfood").submit();

}
});

});	

/* $(function(){

for(var i=0;i<4;i++){

alert(i);

$("<div class='mct clearfix'> <input type='text' class='liaoext zhuliao fcbm' name='zhuliao[]' value=''> <input type='text' class='liangext fcbm' name='zhuliaoValue[]' value=''> <a href='javascript:void(0);' class='add' ></a> <a href='javascript:void(0);' class='up' ></a> <a href='javascript:void(0);' class='down' ></a> <a href='javascript:void(0);' class='wrng'></a> </div>").appendTo("#zl-listmlist");

}

}); */

</script>

</body></html>